<template>
	<view>
		<u-cell-group>
			<u-cell v-for="item in noticeList" :key="item.id" :title="item.name"
				:value="item.status === 1 ? '审核中': '待处理'" size="large" center :url="`/pages/work/rectifyNotice/about?activityId=${item.activityId}&activityName=${activityName}&noticeId=${item.id}
				&areacode=${item.syscode}&areaName=${item.name}`"></u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	import {
		getCityNotice,
		setCityNotice
	} from "@/api/supervise/work.js"
	export default {
		data() {
			return {
				activityId: 0,
				activityName: "",
				noticeList: []
			}
		},
		onLoad(option) {
			this.activityId = option.activityId;
			this.activityName = option.activityName;
			this.getCityNotice();
		},
		methods: {
			getCityNotice() {
				getCityNotice(this.activityId).then(res => {
					this.noticeList = res.notice;
					this.changeNaBtnTitle();
				})
			},
			changeNaBtnTitle() {
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				const tn = currentWebview.getStyle().titleNView;
				if (this.noticeList.length > 0) {
					tn.buttons[0].width = 0;
					currentWebview.setStyle({
						titleNView: tn
					});
				}
			},
			setCityNotice() {
				setCityNotice(this.activityId).then(res => {
					if (res.status === 0) {
						uni.$u.toast("生成完成");
						this.getCityNotice();
					} else {
						uni.$u.toast("生成失败");
					}
				})
			}
		},
		onNavigationBarButtonTap(e) {
			// 点击导航栏自定义按钮
			this.setCityNotice();
		}
	}
</script>

<style>

</style>